import requests


class IHRMApi:

    # 登录接口
    @classmethod
    def login(cls, body):
        url = "http://ihrm2-test.itheima.net/api/sys/login"
        headers = {"Content-Type": "application/json"}
        resp = requests.post(url=url, headers=headers, json=body)
        return resp

        pass

    # 组织架构列表
    @classmethod
    def department_list(cls, token):
        url = "http://ihrm2-test.itheima.net/api/company/department"
        headers = {"Authorization": token}
        resp = requests.get(url=url, headers=headers)
        return resp

    # 获取部门信息
    @classmethod
    def query_department(cls, token, id):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{id}"
        headers = {"Authorization": token}
        resp = requests.get(url=url, headers=headers)
        return resp

    # 部门添加
    @classmethod
    def add_department(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/company/department"
        headers = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=headers, json=body)
        return resp

    # 部门修改
    @classmethod
    def update_department(cls, token, id, body):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{id}"
        headers = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=headers, json=body)
        return resp

    # 部门删除
    @classmethod
    def delete_department(cls, token, id):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{id}"
        headers = {"Authorization": token}
        resp = requests.delete(url=url, headers=headers)
        return resp

    pass
